package avicit.bdp.dgs.metadata.rest;

import avicit.bdp.dgs.metadata.service.CatalogDbmsService;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author mayi 数据目录管理
 */
@RestController
@Api(tags = "数据目录管理")
@RequestMapping("/api/bdp/dgs/category")
public class CatalogController {

  @Resource private CatalogDbmsService catalogDbmsService;

  @ApiOperation(value = "移除目录")
  @ApiParam(value = "资产ID集合", name = "dataAssetIdList", required = true)
  @PostMapping("/dataAsset/delete")
  public ResponseMsg<Boolean> removeFromCatalog(@RequestBody List<String> dataAssetIdList) {
    ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
    responseMsg.setResponseBody(catalogDbmsService.removeFromCatalog(dataAssetIdList));
    return responseMsg;
  }

  @ApiOperation(value = "批量添加")
  @ApiParam(value = "资产ID集合", name = "dataAssetIdList", required = true)
  @PostMapping("/{catalogId}/dataAsset")
  public ResponseMsg<Boolean> batchAddDataAssetCatalog(
      @PathVariable String catalogId, @RequestBody List<String> dataAssetIdList) {
    ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
    responseMsg.setResponseBody(
        catalogDbmsService.batchAddDataAssetCatalog(catalogId, dataAssetIdList));
    return responseMsg;
  }
}
